package org.crumbleworks.crumbcrane.entity;

import static org.lwjgl.opengl.GL11.GL_QUADS;
import static org.lwjgl.opengl.GL11.glBegin;
import static org.lwjgl.opengl.GL11.glEnd;
import static org.lwjgl.opengl.GL11.glTexCoord2f;
import static org.lwjgl.opengl.GL11.glVertex2f;

import java.util.Random;

public class Entity2DUtilities {
    private static Random randomNumberGenerator = new Random();

    public static void render(Entity2D entity) {
        entity.getColor().bind();
        entity.getTexture().bind();
        
        glBegin(GL_QUADS);
            glTexCoord2f(0, 0);
            glVertex2f(entity.getX(), entity.getY() + entity.getHeight()); //lo
            glTexCoord2f(0, 1);
            glVertex2f(entity.getX(), entity.getY()); //lu
            glTexCoord2f(1, 1);
            glVertex2f(entity.getX() + entity.getWidth(), entity.getY()); //ru
            glTexCoord2f(1, 0);
            glVertex2f(entity.getX() + entity.getWidth(), entity.getY() + entity.getHeight()); //ro
        glEnd();
    }
    
    public static long generateRandomID() {
        return randomNumberGenerator.nextLong();
    }
}
